//
//  MSCoinCell.m
//  SocietySale
//
//  Created by Mike on 16/11/18.
//  Copyright © 2016年 Mike. All rights reserved.
//

#import "MSCoinCell.h"

@interface MSCoinCell ()
@property (nonatomic, strong) UILabel  *titleLabel;
@property (nonatomic, strong) GXButton *goBtn;

@end

@implementation MSCoinCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
    }
    return self;
}

- (void)initView {
    self.titleLabel = [self creatLabel:CGRectMake(12, 0, SCREEN_WIDTH, 20)];

    self.goBtn = [[GXButton alloc] initWithFrame:CGRectMake((SCREEN_WIDTH-150)/2, 30, 150, 30)];
    self.goBtn.titleLabel.font = HeitiFont(16);
//    [self.goBtn setBackgroundColor:[UIColor whiteColor]];
    self.goBtn.layer.borderWidth = 1;
    self.goBtn.layer.cornerRadius = 2;
    [self.goBtn addTarget:self action:@selector(goClick) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:self.goBtn];
}

//创建label
- (UILabel*)creatLabel:(CGRect)frame{
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.font = HeitiFont(14);
    label.textColor = [UIColor blackColor];
    [self.contentView addSubview:label];
    return label;
}

- (void)setRowIndex:(NSInteger)rowIndex{
    _rowIndex = rowIndex;
    
    if (rowIndex == 0) {
        self.titleLabel.text = @"1.进行高级会员兑换服务";
        [self.goBtn setTitle:@"去兑换" forState:UIControlStateNormal];
        [self.goBtn setTitleColor:UIColorFromRGB(0xcaa562) forState:UIControlStateNormal];
        self.goBtn.layer.borderColor = UIColorFromRGB(0xcaa562).CGColor;
    }
    else{
        self.titleLabel.text = @"2.进行交易";
        [self.goBtn setTitle:@"去交易" forState:UIControlStateNormal];
        [self.goBtn setTitleColor:kBlueColor forState:UIControlStateNormal];
        self.goBtn.layer.borderColor = kBlueColor.CGColor;
    }
}

- (void)goClick{
    if ([self.delegate respondsToSelector:@selector(selectBtnWithIndex:)]) {
        [self.delegate selectBtnWithIndex:_rowIndex];
    }
}

@end
